/*     */ package com.zimbra.cs.account;
/*     */ 
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.common.soap.Element;
/*     */ import com.zimbra.cs.mailbox.ACL;
/*     */ import com.zimbra.cs.mailbox.MailItem.Type;
/*     */ import com.zimbra.soap.type.ShareInfo;
/*     */ import java.io.PrintStream;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class ShareInfoData
/*     */ {
/*     */   private String mOwnerAcctId;
/*     */   private String mOwnerAcctEmail;
/*     */   private String mOwnerAcctDisplayName;
/*     */   private int mItemId;
/*     */   private String mItemUuid;
/*     */   private String mPath;
/*     */   private MailItem.Type folderDefaultView;
/*     */   private MailItem.Type type;
/*     */   private short mRights;
/*     */   private byte mGranteeType;
/*     */   private String mGranteeId;
/*     */   private String mGranteeName;
/*     */   private String mGranteeDisplayName;
/*     */   private String mUrl;
/*     */   private String mGuestPassword;
/*  57 */   private long mExpiry = 0L;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   private String mMountpointId_zmprov_only;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*  71 */   public void setMountpointId_zmprov_only(String mptId) { this.mMountpointId_zmprov_only = mptId; }
/*     */   
/*     */   public String getMountpointId_zmprov_only() {
/*  74 */     if (this.mMountpointId_zmprov_only == null) {
/*  75 */       return "";
/*     */     }
/*  77 */     return this.mMountpointId_zmprov_only;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public void setOwnerAcctId(String ownerAcctId)
/*     */   {
/*  84 */     this.mOwnerAcctId = ownerAcctId;
/*     */   }
/*     */   
/*     */   public String getOwnerAcctId() {
/*  88 */     return this.mOwnerAcctId;
/*     */   }
/*     */   
/*     */   public void setOwnerAcctEmail(String ownerAcctEmail) {
/*  92 */     this.mOwnerAcctEmail = ownerAcctEmail;
/*     */   }
/*     */   
/*     */   public String getOwnerAcctEmail() {
/*  96 */     return this.mOwnerAcctEmail;
/*     */   }
/*     */   
/*     */   public void setOwnerAcctDisplayName(String ownerAcctDisplayName) {
/* 100 */     this.mOwnerAcctDisplayName = ownerAcctDisplayName;
/*     */   }
/*     */   
/*     */   public String getOwnerAcctDisplayName() {
/* 104 */     return this.mOwnerAcctDisplayName;
/*     */   }
/*     */   
/*     */   public void setItemId(int itemId) {
/* 108 */     this.mItemId = itemId;
/*     */   }
/*     */   
/*     */   public int getItemId() {
/* 112 */     return this.mItemId;
/*     */   }
/*     */   
/*     */   public void setItemUuid(String itemUuid) {
/* 116 */     this.mItemUuid = itemUuid;
/*     */   }
/*     */   
/*     */   public String getItemUuid() {
/* 120 */     return this.mItemUuid;
/*     */   }
/*     */   
/*     */   public void setPath(String path) {
/* 124 */     this.mPath = path;
/*     */   }
/*     */   
/*     */   public String getPath() {
/* 128 */     return this.mPath;
/*     */   }
/*     */   
/*     */   public String getName()
/*     */   {
/* 133 */     String[] fn = this.mPath.split("/");
/* 134 */     return fn.length > 0 ? fn[(fn.length - 1)] : this.mPath;
/*     */   }
/*     */   
/*     */   public void setFolderDefaultView(MailItem.Type view) {
/* 138 */     this.folderDefaultView = view;
/*     */   }
/*     */   
/*     */   public String getFolderDefaultView() {
/* 142 */     return this.folderDefaultView.toString();
/*     */   }
/*     */   
/*     */   public MailItem.Type getFolderDefaultViewCode() {
/* 146 */     return this.folderDefaultView;
/*     */   }
/*     */   
/*     */   public void setType(MailItem.Type type) {
/* 150 */     this.type = type;
/*     */   }
/*     */   
/*     */   public MailItem.Type getType() {
/* 154 */     return this.type == null ? MailItem.Type.UNKNOWN : this.type;
/*     */   }
/*     */   
/*     */   public void setRights(short rights) {
/* 158 */     this.mRights = rights;
/*     */   }
/*     */   
/*     */   public String getRights() {
/* 162 */     return ACL.rightsToString(this.mRights);
/*     */   }
/*     */   
/*     */   public short getRightsCode() {
/* 166 */     return this.mRights;
/*     */   }
/*     */   
/*     */   public void setGranteeType(byte granteeType) {
/* 170 */     this.mGranteeType = granteeType;
/*     */   }
/*     */   
/*     */   public byte getGranteeTypeCode() {
/* 174 */     return this.mGranteeType;
/*     */   }
/*     */   
/*     */   public String getGranteeType() {
/* 178 */     return ACL.typeToString(this.mGranteeType);
/*     */   }
/*     */   
/*     */   public void setGranteeId(String granteeId) {
/* 182 */     this.mGranteeId = granteeId;
/*     */   }
/*     */   
/*     */   public String getGranteeId() {
/* 186 */     return this.mGranteeId;
/*     */   }
/*     */   
/*     */   public void setGranteeName(String granteeName) {
/* 190 */     this.mGranteeName = granteeName;
/*     */   }
/*     */   
/*     */   public String getGranteeName() {
/* 194 */     return this.mGranteeName;
/*     */   }
/*     */   
/*     */   public void setGranteeDisplayName(String granteeDisplayName) {
/* 198 */     this.mGranteeDisplayName = granteeDisplayName;
/*     */   }
/*     */   
/*     */   public String getGranteeDisplayName() {
/* 202 */     return this.mGranteeDisplayName;
/*     */   }
/*     */   
/*     */   public void setUrl(String url)
/*     */   {
/* 207 */     this.mUrl = url;
/*     */   }
/*     */   
/*     */   public String getUrl() {
/* 211 */     return this.mUrl;
/*     */   }
/*     */   
/*     */   public void setGuestPassword(String guestPassword) {
/* 215 */     this.mGuestPassword = guestPassword;
/*     */   }
/*     */   
/*     */   public String getGuestPassword() {
/* 219 */     return this.mGuestPassword;
/*     */   }
/*     */   
/*     */   public void setExpiry(Long expiry) {
/* 223 */     this.mExpiry = expiry.longValue();
/*     */   }
/*     */   
/*     */   public long getExpiry() {
/* 227 */     return this.mExpiry;
/*     */   }
/*     */   
/*     */   public boolean isExpired() {
/* 231 */     return (this.mExpiry != 0L) && (System.currentTimeMillis() > this.mExpiry);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String getOwnerNotifName()
/*     */   {
/* 240 */     String notifName = getOwnerAcctDisplayName();
/* 241 */     if (notifName != null) {
/* 242 */       return notifName;
/*     */     }
/* 244 */     return getOwnerAcctEmail();
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public String getGranteeNotifName()
/*     */   {
/* 253 */     String notifName = getGranteeDisplayName();
/* 254 */     if (notifName != null) {
/* 255 */       return notifName;
/*     */     }
/* 257 */     return getGranteeName();
/*     */   }
/*     */   
/*     */ 
/*     */   public static ShareInfoData fromJaxbShareInfo(ShareInfo sInfo)
/*     */     throws ServiceException
/*     */   {
/* 264 */     ShareInfoData sid = new ShareInfoData();
/*     */     
/* 266 */     sid.setOwnerAcctId(sInfo.getOwnerId());
/* 267 */     sid.setOwnerAcctEmail(sInfo.getOwnerEmail());
/* 268 */     sid.setOwnerAcctDisplayName(sInfo.getOwnerDisplayName());
/* 269 */     sid.setItemId(sInfo.getFolderId());
/* 270 */     sid.setItemUuid(sInfo.getFolderUuid());
/* 271 */     sid.setPath(sInfo.getFolderPath());
/* 272 */     sid.setFolderDefaultView(MailItem.Type.of(sInfo.getDefaultView()));
/* 273 */     sid.setRights(ACL.stringToRights(sInfo.getRights()));
/* 274 */     sid.setGranteeType(ACL.stringToType(sInfo.getGranteeType()));
/* 275 */     sid.setGranteeId(sInfo.getGranteeId());
/* 276 */     sid.setGranteeName(sInfo.getGranteeName());
/* 277 */     sid.setGranteeDisplayName(sInfo.getGranteeDisplayName());
/* 278 */     sid.setMountpointId_zmprov_only(sInfo.getMountpointId());
/*     */     
/* 280 */     return sid;
/*     */   }
/*     */   
/*     */   public static ShareInfoData fromXML(Element eShare) throws ServiceException {
/* 284 */     ShareInfoData sid = new ShareInfoData();
/*     */     
/* 286 */     sid.setOwnerAcctId(eShare.getAttribute("ownerId", null));
/* 287 */     sid.setOwnerAcctEmail(eShare.getAttribute("ownerEmail", null));
/* 288 */     sid.setOwnerAcctDisplayName(eShare.getAttribute("ownerName", null));
/* 289 */     sid.setItemId(Integer.valueOf(eShare.getAttribute("folderId")).intValue());
/* 290 */     sid.setItemUuid(eShare.getAttribute("folderUuid", null));
/* 291 */     sid.setPath(eShare.getAttribute("folderPath", null));
/* 292 */     sid.setFolderDefaultView(MailItem.Type.of(eShare.getAttribute("view", null)));
/* 293 */     sid.setRights(ACL.stringToRights(eShare.getAttribute("rights")));
/* 294 */     sid.setGranteeType(ACL.stringToType(eShare.getAttribute("granteeType")));
/* 295 */     sid.setGranteeId(eShare.getAttribute("granteeId", null));
/* 296 */     sid.setGranteeName(eShare.getAttribute("granteeName", null));
/* 297 */     sid.setGranteeDisplayName(eShare.getAttribute("granteeDisplayName", null));
/*     */     
/*     */ 
/* 300 */     sid.setMountpointId_zmprov_only(eShare.getAttribute("mid", null));
/*     */     
/* 302 */     return sid;
/*     */   }
/*     */   
/*     */   public ShareInfo toJAXB(Integer mptId) {
/* 306 */     ShareInfo jaxb = new ShareInfo();
/* 307 */     jaxb.setOwnerId(getOwnerAcctId());
/* 308 */     jaxb.setOwnerEmail(getOwnerAcctEmail());
/* 309 */     jaxb.setOwnerDisplayName(getOwnerAcctDisplayName());
/* 310 */     jaxb.setFolderId(getItemId());
/* 311 */     jaxb.setFolderUuid(getItemUuid());
/* 312 */     jaxb.setFolderPath(getPath());
/* 313 */     jaxb.setDefaultView(getFolderDefaultView());
/* 314 */     jaxb.setRights(getRights());
/* 315 */     jaxb.setGranteeType(getGranteeType());
/* 316 */     jaxb.setGranteeId(getGranteeId());
/* 317 */     jaxb.setGranteeName(getGranteeName());
/* 318 */     jaxb.setGranteeDisplayName(getGranteeDisplayName());
/* 319 */     if (mptId != null) {
/* 320 */       jaxb.setMountpointId(mptId.toString());
/*     */     }
/* 322 */     return jaxb;
/*     */   }
/*     */   
/*     */   public String toString()
/*     */   {
/* 327 */     String format = "    %15s : %s\n";
/* 328 */     StringBuffer sb = new StringBuffer();
/* 329 */     sb.append(String.format(format, new Object[] { "owner id", getOwnerAcctId() }));
/*     */     
/* 331 */     sb.append(String.format(format, new Object[] { "owner email", getOwnerAcctEmail() }));
/*     */     
/* 333 */     sb.append(String.format(format, new Object[] { "owner display", getOwnerAcctDisplayName() }));
/*     */     
/* 335 */     sb.append(String.format(format, new Object[] { "folder id", String.valueOf(getItemId()) }));
/*     */     
/* 337 */     sb.append(String.format(format, new Object[] { "folder uuid", getItemUuid() }));
/*     */     
/* 339 */     sb.append(String.format(format, new Object[] { "folder path", getPath() }));
/*     */     
/* 341 */     sb.append(String.format(format, new Object[] { "view", getFolderDefaultView() }));
/*     */     
/* 343 */     sb.append(String.format(format, new Object[] { "rights", getRights() }));
/*     */     
/* 345 */     sb.append(String.format(format, new Object[] { "mountpoint id", getMountpointId_zmprov_only() }));
/*     */     
/* 347 */     sb.append(String.format(format, new Object[] { "grantee type", getGranteeType() }));
/*     */     
/* 349 */     sb.append(String.format(format, new Object[] { "grantee id", getGranteeId() }));
/*     */     
/* 351 */     sb.append(String.format(format, new Object[] { "grantee email", getGranteeName() }));
/*     */     
/* 353 */     sb.append(String.format(format, new Object[] { "grantee display", getGranteeDisplayName() }));
/*     */     
/* 355 */     return sb.toString();
/*     */   }
/*     */   
/*     */   public void dump() {
/* 359 */     System.out.println();
/* 360 */     System.out.println(toString());
/* 361 */     System.out.println();
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/ShareInfoData.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */